<template>
	<view class="container">
		<u-list :lowerThreshold="50" :height="`${clientHeight}px`" @scrolltolower="scrolltolower">
			<u-swipe-action >
				<u-swipe-action-item size="large" v-for="(item, index) in company" :key="index" :options="option">
					<u-list-item height="150rpx">
						<u-cell size="large"  :title="item.name" @click="showDetail(item)" @touchstart="showDetail(item)"
							arrow-direction="right">
							<!-- <template #>
					      	<uni-icons type="right"></uni-icons>
					      </template> -->
						</u-cell>
					</u-list-item>
				</u-swipe-action-item>
			</u-swipe-action>
		</u-list>
	</view>
</template>

<script>
	// import OrderList from './OrderList.vue'
	import {
		getCompany,
		getOrderList
	} from '@/api/index'
	const app = getApp()
	export default {
		name: 'listView',
		components: {
			// OrderList
		},
		props:{
			value:{
				type:Array,
				default:[]
			}
		},
		data() {
			return {
				clientHeight: app.globalData.clientHeight - 50 - 50 - 30,
				loading: false,
				refreshing: false,
				finished: false,
				total: 0,
				queryParam: {
					pageSize: 15,
					pageNum: 1,
					id: null,
					companyId: null,
					name: null
				},
				show: {
					index: null,
					details: []
				},
				option: [{
						text: '新建订单',
						style: {
							backgroundColor: 'green'
						}
					}]
			}
		},
		computed: {
			maxPage() {
				return Math.ceil(this.total / this.queryParam.pageSize) > 0 ? Math.ceil(this.total / this.queryParam
					.pageSize) : 1
			},
			company(){
				return this.value
			}
		},
		methods: {
			scrolltolower(){
				if(this.company.length%this.queryParam.pageSize == 0){
					console.log('scrolltolower')
					this.$emit('getNext')
				}
			},
			async showDetail(row) {
				this.show = row
				console.log(row)
				this.$emit("goList", row.id, row.companyId)
			},
			beforeClose(params) {
				console.log(params)
			},
		}
	}
</script>

<style scoped lang="scss">
	.container {
		width: 100%;
		// height: calc(100vh-200rpx) !important;
		overflow-y: scroll;
		padding-top: 50rpx;
	}

	.van-list {
		width: 100%;
	}

	.van-cell {
		width: 100%;
		height: 120rpx;
		line-height: 120rpx;
	}

	.van-button--danger {
		height: 100%;
	}
	.u-swipe-action-item{
		height: 130rpx;
	}
	 .u-list-item{
		height: 130rpx;
	}
	.u-cell{
		height: 130rpx;
		border-bottom: 1rpx solid rgb(214, 215, 217);
		font-size: 28rpx;
	}
	::v-deep .u-cell__body{
		height: 130rpx;
	}
	::v-deep .u-cell__title-text{
		line-height: 130rpx;
	}
	.u-cell__title-text--large{
		font-size: 30rpx;
	}

</style>